<?php

namespace App\Jobs;

use App\Imports\ImportsExcel;
use App\Models\Local\UserModel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Maatwebsite\Excel\Facades\Excel;

class ImportsExcelJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $format;
    public $model;
    public $path;
    public function __construct($format, $model, $path)
    {
        $this->format = $format;
        $this->model = $model;
        $this->path = $path;
    }

    public function handle()
    {
        Excel::import(new ImportsExcel($this->format, $this->model), $this->path);
    }

    public function fail($exception = null)
    {

    }
}
